home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-21 | 9.8 KB | 291 lines | [TEXT/R*ch] |
-
-
-
- CRON
- ——————————————————————————————————————————————————————————————
-
-
- NAME
-
- cron - clock daemon
-
-
- DESCRIPTION
-
- The cron daemon executes commands at specified dates and
- times according to the instructions in the crontab file.
- Since cron never exits, it should only be executed once.
- This is best done by placing an alias to cron in the
- System 7 "Startup Items" folder. Cron will then be exec-
- uted automatically during system startup.
-
- The crontab file consists of lines of seven fields each.
- The fields are separated by spaces or tabs. The first five
- fields are integer patterns that specify:
-
- o Minute (0-59)
- o Hour (0-23)
- o Day of the month (1-31)
- o Month of the year (1-12)
- o Day of the week (1-7, with 1=Monday)
-
- Each pattern can contain:
-
- o A number in the range above.
- o Two numbers separated by a minus (-) sign means an
- inclusive range. The final element of the range can now
- be an asterisk (*), which will represent the largest
- permissible value in any given field. Support for an
- asterisk here is non-standard, and not part of the UNIX
- cron specification.
- o A list of numbers separated by commas means any of the
- numbers.
- o An asterisk (*) means all legal values.
-
- The sixth field is a user name. This is required for compat-
- ibility, but is not currently used. Supply a dummy value in
- this field.
-
- The seventh field consists of all text on the line after the
- sixth field, including tabs and spaces. This field is the
- command that is executed at the specified times. If the
- seventh field begins with "-b", the command that follows will
- be executed in the background. Otherwise, commands are
- initially launched into the forground.
-
- Incorrectly constructed lines are ignored. No errors are
- reported to the user.
-
- The crontab file is examined for changes by cron every minute,
- on the minute.
-
- Ultimately, cron should be setup as a faceless background task,
- but for the moment, it still has a face, so it can be seen in
- and selected from System 7's application menu. When cron is in
- the foreground, hitting (almost) any key on the keyboard will
- cause it to quit.
-
-
- EXTENSIONS TO THE CRONTAB FORMAT
-
- This version of cron for the Mac adds some unique extensions to
- the crontab format in order to allow scheduling on the basis of
- things other than just time and date. (Obviously, these are
- non-standard, but they can be useful.)
-
- These extensions are added to the beginning of valid lines in
- the crontab file. They begin with a word specifying the type of
- case they represent, continue with a case-specific number of
- parameters, and conclude with a colon (:). Following the colon
- should be a normal, 7 field crontab line as detailed in the
- preceding section of this document.
-
- Example:
-
- idle 4-* : * * * * * nobody -b beep
-
- The example above begins with the word specifying the case
- ("idle"), includes a numeric parameter ("4-*"), terminates the
- special case portion of the line with a colon (:), and then
- goes on with a perfectly normal crontab line which happens to
- invoke the "beep" command in the background.
-
- Note that all the numeric values discussed below can be a
- single value, a range of values, a list of values, or an
- asterisk (*) representing all values.
-
- Also, remember that cron still executes commands only once a
- minute, on the minute.
-
- startup
-
- Schedules execution of a command relative to the time at
- which the cron application is launched.
-
- Format: startup N : (normal crontab line)
-
- N is the number of minutes after startup at which the
- command should be executed.
-
- idle
-
- Schedules execution of a command relative to the length of
- time the Mac has been idle, where "idle" means that the
- mouse has not moved and the keyboard has not been used.
- Perfect detection of keyboard use is not possible from an
- application, so don't be surprised if this case isn't
- always handled perfectly, particularly with small delay
- values.
-
- Format: idle N : (normal crontab line)
-
- N is the number of minutes after the Mac goes idle at which
- the command should be executed.
-
- idlescreen
-
- Works just like the "idle" case, but is also sensitive to
- the corner (if any) of the main screen in which the mouse
- is located. This is perfect for writing your own screen
- savers.
-
- Format: idlescreen N A D : (normal crontab line)
-
- N is the number of minutes after the Mac goes idle at which
- the command should be executed.
-
- A is the number of the main screen corner which should
- cause the command to be executed. (See diagram below.)
-
- D is the number of the main screen corner which should
- prevent the command from being executed. (See diagram
- below.)
-
- Screen Corner Numbers:
-
- 1---------2 0 -- No corner.
- | | 1 -- Upper-left corner.
- | 0 | 2 -- Upper-right corner.
- | | 3 -- Lower-left corner.
- 3---------4 4 -- Lower-right corner.
-
- Screen corners are 32x32 squares, so positioning the
- mouse in them is no challenge.
-
- busy
-
- Schedules execution of a command relative to the length of
- time the Mac has been busy, where "busy" means that the
- mouse has been moved and/or the keyboard is in use. (The
- same caveats that apply to the idle command also apply
- here.)
-
- Format: busy N : (normal crontab line)
-
- N is the number of minutes after the Mac becomes busy at
- which the command should be executed.
-
-
- DEBUGGING FEATURES (POTENTIALLY USEFUL)
-
- With cron in the foreground the following keys do something
- other than forcing cron quit. They just might be useful to
- you.
-
- d Calls DebugStr() to get you into MacsBug in cron's
- context.
-
- s Translates the tokenized, memory-resident version of the
- crontab file which cron is currently using into ASCII
- and writes it out to a file named "crontab export" in
- the same directory as the cron application. This is
- handy if you're trying to track down incorrectly con-
- structed (and therefore ignored) lines in the crontab
- file.
-
- Another feature which aids debugging is the "cron log" file
- which records what commands are executed and when. It does
- not record whether or not the commands worked, just whether
- or not they were invoked.
-
-
- NOTES
-
- Unlike the UNIX cron, a % character in the seventh and following
- fields is not translated to a newline character.
-
- Escape sequences are supported in all fields, so preceding a
- character by a backslash (\) will cause the character to be
- ignored for parsing purposes. In addition, the standard set of
- escape sequences are supported:
-
- \a alert (bell) character
- \b backspace
- \f formfeed
- \n newline
- \r carriage return
- \t horizontal tab
- \v vertical tab
- \\ backslash
- \? question mark
- \' single quote
- \" double quote
-
- Hexadecimal (\xhh) and Octal (\ooo) sequences are not
- currently supported, however.
-
- Double quotes can be used to delimit fields. For example, the
- file name "Captain’s Suite" is interpreted as a single field if
- it is surrounded by double quotes, but as two fields ("Captain’s"
- and "Suite") if the quotes are omitted. The parsing code is not
- currently sensitive to single quotes.
-
-
- CRON AS AN APPLICATION
-
- Ultimately, cron will be a faceless background program which
- won't appear in the application menu. For development purposes,
- however, it's more convenient to allow it to show-up there. It
- still doesn't have any sort of user interface, but you can (at
- least) force it to quit by selecting it in the application menu
- and hitting any key. Cron should quit immediately.
-
- No user interface helps guarantee that cron runs in the smallest
- possible amount of memory. It currently runs in 34K and will
- probably work perfectly well in less.
-
- Any user interface that is eventually created will be a separate
- program.
-
-
- ARGUMENT PASSING
-
- If you are interested in writing commands for cron, read the
- following. If not, ignore the rest of this file.
-
- One of the things that makes cron capable of doing useful things
- is its ability to pass arguments to the programs it executes.
- Since the Mac OS has virtually no provision for argument passing,
- a scheme had to be invented for cron.
-
- Cron passes arguments to the programs it executes in a custom
- AppleEvent. In order to get its arguments, a program must call
- a routine named argcReceiver which will wait as much as one min-
- ute for the appropriate AppleEvent to arrive. If the arguments
- are not received within one minute, argcReceiver calls
- ExitToShell to terminate the program.
-
- ArgcReceiver takes two parameters: a pointer to an argc and an
- argv variable. The call typically looks like this:
-
- void main() {
- int argc;
- char **argv;
-
- argcReceiver(&argc, &argv);
-
- /* Put the rest of your main procedure down here.... */
-
- }
-
- Normally, you'll call argcReceiver before your main does anything
- else. Once you've made the call, argc and argv will be filled out
- *exactly* as they would be in a normal C programming environment.
- So, apart from having to make this one procedure call at the start
- of your main program in order to get at your arguments, you can use
- the arguments exactly as you're accustomed to doing so in other
- environments, like UNIX.
-
- Note that cron provides no support for stdin, stdout, stderr or
- exit return values. Work is underway on a separate product that
- will support all this and more, however.
-
- The source code for argcReceiver is in the cron folder along with
- the source code for argcBuilder - a collection of routines which
- make it fast and painless to assemble and transmit the argument
- AppleEvents to other programs.
-
-
-
-
-